import tkinter, os, pygubu
from concurrent.futures import ThreadPoolExecutor
import time
from tkinter import messagebox, StringVar


class Show():
    text_str = ''

    def __init__(self, master, title, content):
        fpath = "show.ui"
        # print(content, title)
        self.titles = title
        title += "\n\n\n\n"
        self.contents = title + content
        self.builder = builder = pygubu.Builder()

        builder.add_from_file(fpath)
        mainwindow = builder.get_object('Toplevel_1', master)

        bk = builder.get_object("close")
        bk['command'] = self.on_get_link
        self.title = builder.get_object('title', master)
        self.title.config(text='asdasdasdasdasd')
        self.content = builder.get_object('content', master)
        self.content.insert(0.0, self.contents)
        master.update()
        self.root1 = master

    def loads(self):
        messagebox.askquestion("欢迎使用", "欢迎使用本软件")

    def on_get_link(self):
        with open(self.titles + '.txt', 'w') as f:
            f.write(self.contents)
        messagebox._show('下载成功', message=self.titles + ' 下载成功')

    def quits(self, event):
        messagebox.showerror("", "您准备退出了")


# if __name__ == "__main__":
#     root = tkinter.Toplevel()
#     mainwindow = Show(root, '', '')
#     root.mainloop()
